using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Data.Common;
using MacomberMap.Common.Components;
using MacomberMap.Common.User_Interfaces.Components;

namespace MacomberMap.Common.Types
{
    /// <summary>
    /// This class holds zonal information (weather and load)
    /// </summary>
    [MM_Serializable_Target(MM_Serializable_Target.enumTargetType.TypeCollection)]
    public class MM_Zone : MM_Element
    {
        /// <summary>The integer locator for SQL CIM Servers</summary>
        [MM_Serializable_Target(MM_Serializable_Target.enumTargetType.Index)]
        public int Index;

        /// <summary>Override TEID so it's not serialized</summary>
        [MM_Serializable_Target(MM_Serializable_Target.enumTargetType.None)]        
        public new UInt64 TEID = 0;

        /// <summary>The collection of substations within this zone</summary>
        public List<MM_Substation> Substations = new List<MM_Substation>();

        /// <summary>Override KVLevel so it's not serialized</summary>
        [MM_Serializable_Target( MM_Serializable_Target.enumTargetType.None)]
        public new MM_KVLevel KVLevel = null;

        /// <summary>Override owner so it's not serialized</summary>
        [MM_Serializable_Target(MM_Serializable_Target.enumTargetType.None)]
        public new MM_Company Owner = null;

        /// <summary>Override operator so it's not serialized</summary>
        [MM_Serializable_Target(MM_Serializable_Target.enumTargetType.None)]
        public new MM_Company Operator = null;

        /// <summary>Override substation so it's not serialized</summary>
        [MM_Serializable_Target(MM_Serializable_Target.enumTargetType.None)]
        public new MM_Substation Substation= null;

        /// <summary>Override element type so it's serialized</summary>
        [MM_Serializable_Target(MM_Serializable_Target.enumTargetType.TypeCollection)]
        public new MM_Element_Type ElemType
        {
            get { return base.ElemType; }
            set { base.ElemType = value; }
        }

        /// <summary>
        /// Initialize a new weather or load zone.
        /// </summary>
        /// <param name="ElementSource">The data row containing the source</param>        
        public MM_Zone(DbDataReader ElementSource): base(ElementSource)
        {            
        }

        /// <summary>
        /// Create a new zone from XML
        /// </summary>
        /// <param name="ZoneSource">The XML configuration element for the zone</param>        
        public MM_Zone(XmlElement ZoneSource) : base(ZoneSource) {
       }

        /// <summary>
        /// Create a new zone with specified integer value and name
        /// </summary>
        /// <param name="Name">The name</param>
        /// <param name="Index">The index of the zone</param>
        /// <param name="ElemType">The element type to be assigned to this zone</param>
        public MM_Zone(string Name, int Index, MM_Element_Type ElemType)
        {
            this.Index = Index;
            this.Name = Name;
            this.ElemType = ElemType;
        }

        /// <summary>
        /// Return the name of the zone
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return this.Name;
        }
    }
}
